/** 查询字符串传参：商品详情模块 */
import React, { Component } from 'react'

import qs from "qs"

export default class Detail extends Component {

  componentDidMount() {
    console.log("Detail组件挂载完成")
  }

  componentWillUnmount() {
    console.log("Detail组件销毁")
  }

  render() {
    console.log(this, "Detail组件 this")

    // 解构获取参数
    let { search } = this.props.location
    let params = qs.parse(search, { ignoreQueryPrefix: true })
    console.log(params, "接收到的参数")

    return (
      <div>
        <h3>商品详情模块</h3>
        <h4>商品名称：{params.name}</h4>
        <h4>商品编号：{params.id}</h4>
      </div>
    )
  }
}
